import { View, Text, Button } from "@tarojs/components";
import Taro, { useLoad } from "@tarojs/taro";
import "./index.scss";

export default function Home() {
  useLoad(() => {
    console.log("Page loaded.");
  });

  const scanCode = () => {
    Taro.scanCode({
      success: async (res) => {
        console.log(res);
        const result = { isBind: false };
        if (result.isBind) {
        } else {
          Taro.navigateTo({
            url: "/pages/bind-process/index",
          });
        }
      },
    });
  };

  return (
    <View className="index">
      <Button
        onTap={() => {
          console.log("click");
          scanCode();
        }}
      >
        绑定仪器
      </Button>
    </View>
  );
}
